/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <cstdio>
#include <cstring>
using namespace std;
const int N=1e5;
int scores[N+1];
int main_1032()
{
    memset(scores,0,sizeof(scores));
    int n,id,score,max_id;
    scanf("%d",&n);
    scanf("%d%d",&max_id,&score);
    scores[max_id]+=score;
    for (int i=1;i<n ;++i )
    {
        scanf("%d%d",&id,&score);
        scores[id]+=score;
        if (scores[max_id]<scores[id])
        {
            max_id=id;
        }
    }
    printf("%d %d\n",max_id,scores[max_id]);
	return 0;
}
